<HTML>   
<TITLE>JDComPort JavaScript Sample</TITLE>   
<HEAD>   
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
   
<object classid="clsid:C4751F74-C039-4272-8532-11F7ACBAD184"   
          name="JDComPort1"  
          Width="32"   
          height="32"   
          
>   
</object>   
   
<script type="text/javascript">   
   
//函数与方法   
   
	function AddInfo(sInf)   
		{   
		document.getElementById("mbox").value = "\r" +sInf +document.getElementById("mbox").value;   
		}   
   
	function Open()   
		{   
		  JDComPort1.Open();   
		}   
   
	function Close()   
		{   
		  JDComPort1.Close();   
		}   
   
	function SetState()   
		{   
		  JDComPort1.SetSate();   
		}   
   
	function SetupPorts()   
		{   
		  JDComPort1.SetupPorts();   
		}   
   
	function ClearmBox()   
		{   
		  document.getElementById("mbox").value = "";   
		}   
   
//事件与消息   
//按键事件   
	function OnKeyPress(key,devid)   
		{   
		  document.getElementById("Key_Dev").value =devid+ ":"+key;   
		  AddInfo(devid+":"+key);   
		}   
   
	//来电事件   
	function OnRead(s,t,devid,wavefile)   
		{   
		  document.getElementById("CallerID").value =devid+ ":"+ s +"   "+  wavefile;   
		  AddInfo(devid+ ":"+ s +"   "+  wavefile);   
		}     
   
	function OnOpen()   
		{   
		  AddInfo("Open");   
		}   
   
	function OnClose()   
		{   
		  AddInfo("Close");   
		}   
</script>   
   
<script type="text/javascript">   
  JDComPort1.attachEvent("OnClose",OnClose);     
  JDComPort1.attachEvent("OnKeyPress",OnKeyPress);     
  JDComPort1.attachEvent("OnRead",OnRead);     
  JDComPort1.attachEvent("OnOpen",OnOpen);     
</script>   
   
</HEAD>   
   
   
   
<BODY>   
  <form action="#" name="forms">   
    <table width="100%" border="1" cellpadding="0" cellspacing="0" onload height="330">   
      <tr>     
        <td width="9%" height="30"><h3>JDComPort.OCX 控件来电实例 </h3></td>   
      </tr>   
      <tr>     
        <td width="9%" height="30">  
        来电   
        <INPUT TYPE=text SIZE=52 NAME="CallerID" >   
        按键   
        <INPUT TYPE=text SIZE=10 NAME="Key_Dev">   
   
        </td>   
      </tr>   
      <tr>     
        <td width="9%" height="30">  
         消息窗口<br>   
        <textarea name="mbox" cols="80" rows="10">   
        </textarea>   
        </td>   
      </tr>   
      <tr>   
        <td width="9%" height="30">   
        <INPUT TYPE=button VALUE="系统设置" ONCLICK="SetState()" NAME="Button1">   
        <INPUT TYPE=button VALUE="查找设备" ONCLICK="SetupPorts()" NAME="Button4">   
        <INPUT TYPE=button VALUE="打开设备" ONCLICK="Open()" NAME="OpenDev">   
        <INPUT TYPE=button VALUE="关闭设备" ONCLICK="Close()" NAME="Button11">   
        <INPUT TYPE=button VALUE="清除显示" ONCLICK="ClearmBox()" NAME="MsClear">   
        </td>   
      </tr>   
    </table>   
  </form>  
</BODY>   
</HTML>